<?php

/**
 * This is the model class for table "building_construction".
 *
 * The followings are the available columns in table 'building_construction':
 * @property integer $id
 * @property integer $no_of_storey
 * @property string $height_of_building
 * @property string $units_of_measurement_in_height
 * @property integer $portion_occupied
 * @property integer $area_per_floor
 * @property integer $beam
 * @property integer $column
 * @property string $flooring
 * @property string $exterior_wall
 * @property string $corridor_wall
 * @property integer $room_partition
 * @property integer $main_stair
 * @property integer $window
 * @property integer $ceiling
 * @property integer $main_door
 * @property integer $truss
 * @property integer $roof
 * @property integer $total_floor_area_occupied
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class BuildingConstruction extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BuildingConstruction the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'building_construction';
	}
const a = "Foot";
const b ="Inches";
public function getMeasurement(){
return array(
self::a=>"Foot",
self::b=>"Inches"
);


}
	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('no_of_storey, portion_occupied, area_per_floor, beam, column, room_partition, main_stair, window, ceiling, main_door, truss, roof, total_floor_area_occupied, inspection_id', 'numerical', 'integerOnly'=>true),
			array('height_of_building', 'length', 'max'=>11),
			array('units_of_measurement_in_height', 'length', 'max'=>6),
			array('flooring, exterior_wall, corridor_wall', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, no_of_storey, height_of_building, units_of_measurement_in_height, portion_occupied, area_per_floor, beam, column, flooring, exterior_wall, corridor_wall, room_partition, main_stair, window, ceiling, main_door, truss, roof, total_floor_area_occupied, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'no_of_storey' => 'No Of Storey',
			'height_of_building' => 'Height Of Building',
			'units_of_measurement_in_height' => 'Units Of Measurement In Height',
			'portion_occupied' => 'Portion Occupied',
			'area_per_floor' => 'Area Per Floor',
			'beam' => 'Beam',
			'column' => 'Column',
			'flooring' => 'Flooring',
			'exterior_wall' => 'Exterior Wall',
			'corridor_wall' => 'Corridor Wall',
			'room_partition' => 'Room Partition',
			'main_stair' => 'Main Stair',
			'window' => 'Window',
			'ceiling' => 'Ceiling',
			'main_door' => 'Main Door',
			'truss' => 'Truss',
			'roof' => 'Roof',
			'total_floor_area_occupied' => 'Total Floor Area Occupied',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('no_of_storey',$this->no_of_storey);
		$criteria->compare('height_of_building',$this->height_of_building,true);
		$criteria->compare('units_of_measurement_in_height',$this->units_of_measurement_in_height,true);
		$criteria->compare('portion_occupied',$this->portion_occupied);
		$criteria->compare('area_per_floor',$this->area_per_floor);
		$criteria->compare('beam',$this->beam);
		$criteria->compare('column',$this->column);
		$criteria->compare('flooring',$this->flooring,true);
		$criteria->compare('exterior_wall',$this->exterior_wall,true);
		$criteria->compare('corridor_wall',$this->corridor_wall,true);
		$criteria->compare('room_partition',$this->room_partition);
		$criteria->compare('main_stair',$this->main_stair);
		$criteria->compare('window',$this->window);
		$criteria->compare('ceiling',$this->ceiling);
		$criteria->compare('main_door',$this->main_door);
		$criteria->compare('truss',$this->truss);
		$criteria->compare('roof',$this->roof);
		$criteria->compare('total_floor_area_occupied',$this->total_floor_area_occupied);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}